<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Spec::Mocks::ExampleMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Spec::Mocks::ExampleMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/mocks/spec_methods_rb.html">
                vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000207">allow_message_expectations_on_nil</a>&nbsp;&nbsp;
      <a href="#M000204">mock</a>&nbsp;&nbsp;
      <a href="#M000205">stub</a>&nbsp;&nbsp;
      <a href="#M000206">stub_everything</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="ArgumentConstraints.html">Spec::Mocks::ArgumentConstraints</a></span>
      </div>
    </div>

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000207" class="method-detail">
        <a name="M000207"></a>

        <div class="method-heading">
          <a href="#M000207" class="method-signature">
          <span class="method-name">allow_message_expectations_on_nil</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Disables warning messages about expectations being set on nil.
</p>
<p>
By default warning messages are issued when expectations are set on nil.
This is to prevent false-positives and to catch potential bugs early on.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000207-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000207-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb, line 40</span>
40:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">allow_message_expectations_on_nil</span>
41:         <span class="ruby-constant">Proxy</span>.<span class="ruby-identifier">allow_message_expectations_on_nil</span>
42:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000204" class="method-detail">
        <a name="M000204"></a>

        <div class="method-heading">
          <a href="#M000204" class="method-signature">
          <span class="method-name">mock</span><span class="method-args">(name, stubs_and_options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Shortcut for creating an instance of <a
href="Mock.html">Spec::Mocks::Mock</a>.
</p>
<p>
<tt>name</tt> is used for failure reporting, so you should use the role
that the <a href="ExampleMethods.html#M000204">mock</a> is playing in the
example.
</p>
<p>
<tt>stubs_and_options</tt> lets you assign options and <a
href="ExampleMethods.html#M000205">stub</a> values at the same time. The
only option available is :null_object. Anything else is treated as a <a
href="ExampleMethods.html#M000205">stub</a> value.
</p>
<h2>Examples</h2>
<pre>
  stub_thing = mock(&quot;thing&quot;, :a =&gt; &quot;A&quot;)
  stub_thing.a == &quot;A&quot; =&gt; true

  stub_person = stub(&quot;thing&quot;, :name =&gt; &quot;Joe&quot;, :email =&gt; &quot;joe@domain.com&quot;)
  stub_person.name =&gt; &quot;Joe&quot;
  stub_person.email =&gt; &quot;joe@domain.com&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000204-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000204-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb, line 23</span>
23:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mock</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">stubs_and_options</span>={})
24:         <span class="ruby-constant">Spec</span><span class="ruby-operator">::</span><span class="ruby-constant">Mocks</span><span class="ruby-operator">::</span><span class="ruby-constant">Mock</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">stubs_and_options</span>)
25:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000205" class="method-detail">
        <a name="M000205"></a>

        <div class="method-heading">
          <span class="method-name">stub</span><span class="method-args">(name, stubs_and_options={})</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="ExampleMethods.html#M000204">mock</a>
</p>
        </div>
      </div>

      <div id="method-M000206" class="method-detail">
        <a name="M000206"></a>

        <div class="method-heading">
          <a href="#M000206" class="method-signature">
          <span class="method-name">stub_everything</span><span class="method-args">(name = 'stub')</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Shortcut for creating a <a href="ExampleMethods.html#M000204">mock</a>
object that will return itself in response to any message it receives that
it hasn&#8216;t been explicitly instructed to respond to.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000206-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000206-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb, line 32</span>
32:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stub_everything</span>(<span class="ruby-identifier">name</span> = <span class="ruby-value str">'stub'</span>)
33:         <span class="ruby-identifier">mock</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">:null_object</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>)
34:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>